Ext.define('appmod.view.knowledge.category.TreeDashboard', {
    extend: 'Ext.panel.Panel',
    alias: [
		'widget.knowledge.category.treedashboard',
		'widget.knowledge-category-treedashboard'
	],
	requires: [
		'appmod.view.knowledge.category.TreeGrid'
	],	
	border : false,
	margins:"5 5 5 5",

	constructor: function (config) {
		
		if (config.fieldStores) {
			this.stores = config.stores;
		}
        this.callParent(arguments);
     },

    initComponent: function() {
        var me = this;
		
		var dsCategory = me.stores['category'];

        Ext.applyIf(me,{
		    layout : {
				type:'border'
			},
			items:[
				{
					store:dsCategory,
			        rootVisible: false,
			        useArrows: true,
			        frame: true,
					title:'经验积累目录',
					xtype:'knowledge.tree.grid',
					region:'center',
					plugins: [
						Ext.create('Ext.grid.plugin.CellEditing', {
							clicktoEdit:2
		    			})
					],
					columns:[{
		            	xtype: 'treecolumn', //this is so we know which column will show the tree
		            	text: '经验积累目录',
		            	flex: 2,
		            	sortable: true,
		            	dataIndex: 'text',
						editor:{
							xtype:'textfield',
							allowBlank: false
						}
		        	}],					
					dockedItems:[
						{
							xtype:'toolbar',
							dock:'top',
							items:[
								{
									text:'刷新',
									action:'reflashCategory'
								},
								{
									text:'保 存',
									action:'saveCategoryUpdate'
								},
								{
									text:'添 加',
									action:'addCategory'
								},
								{
									text:'删 除',
									action:'deleteCategory'
								},
								'-',
		                       	{
		                            xtype: 'button',
		                            text: '用户设定',
									action : 'assignPermissionToUser'
		                        },
		                       	{
		                            xtype: 'button',
		                            text: '用户组设定',
									action : 'assignPermissionToUserGroup'
		                        }								
							]
						}
					]					
				}
			]
		});
        me.callParent(arguments);
    }
});